package com.example.demo.mapper;

import com.example.demo.entity.User;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Description: 对用户表进行操作
 * @Param:
 * @return:
 * @Author: Zwill
 * @Date: 2019/12/25
 */
@Mapper
@Repository
public interface UserMapper {
//    @Results(id = "userMap", value = {
//            @Result(id = true, column = "id", property = "id"),
//            @Result(column = "appid", property = "appid"),
//            @Result(column = "username", property = "username"),
//            @Result(column = "passwd", property = "passwd"),
//            @Result(column = "createtime", property = "createtime"),
////            @Result(property = "useraccount" ,column = "uid")
//    })

    /*添加用户*/
    @Insert("insert into user(id,appid,username,passwd,createtime)values(#{id},#{appid},#{username},#{passwd},#{createtime})")
    int insertUser(User user);

    /*删除用户*/
    @Delete("delete from user where id = #{id}")
    int deleteUser(int id);

    /*修改用户信息*/
    @Update("update user set appid=#{appid},username=#{username},passwd=#{passwd},createtime=#{createtime} where id = #{id}")
    int updateUser(User user);

    /*查询所有用户信息*/
    @Select("select * from user")
    List<User> selectAllUsers();

    /*查询所有主键信息*/
    @Select("select id from user")
    List<Integer> findAllIds();

}
